package com.rayinhz.bet.interceptor;

import java.util.Map;

/**
 * 
 * AuthHolder.java created at 2017年8月22日 下午8:10:32
 * @author Ray [email:rayinhangzhou@hotmail.com]
 * Revision History
 * Date            Programmer                   Notes
 * ----------------------------------------------------------
 **/
public class AuthHolder {
	private static ThreadLocal<Map<String, String>> threadLocal = new ThreadLocal<>();
	
	public static void map(Map<String,String> map){
		threadLocal.set(map);
	}
	
	public static void clear(){
	    Map<String,String> map = threadLocal.get();
	    if(map!=null){
	        map.clear();
	    }
	}
	
	public static String name(){
		return get("name");
	}
	
	public static String mail(){
		return get("mail");
	}
	
	public static String token(){
		return get("token");
	}
	
	public static String type(){
		return get("type");
	}
	
	
	
	private static String get(String key){
		Map<String,String> map = threadLocal.get();
		if(map == null){
			return null;
		}
		return map.get(key);
	}
	
}
